/**
 * Project: greenline-epay-web-home
 * 
 * File Created at 2013-4-9
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package com.greenline.pay.web.common.utils;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @Type HttpUtils
 * @Desc
 * @author jianyun.zheng
 * @date 2013-4-9
 * @Version V1.0
 */
public class HttpUtils {
    private static final Log logger = LogFactory.getLog(HttpUtils.class);

    /**
     * 获取当前页面url,需要加异常处理
     * 
     * @param request
     * @return String
     */
    public static String getRequestUrl(HttpServletRequest request) {
        StringBuilder urlBuilder = new StringBuilder();
        try {
            urlBuilder.append(request.getRequestURI());
            String querystring = request.getQueryString();
            if (StringUtils.isNotBlank(querystring)) {
                urlBuilder.append("?").append(querystring);
            }
        } catch (Exception e) {
            logger.error(e);
        }
        return urlBuilder.toString();
    }

}
